/**
 * 
 */
package com.youxin.cpcenter.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.youxin.busfoundation.bean.leads.LeadsStatTotalBean;
import com.youxin.busfoundation.common.BusinessDataException;
import com.youxin.cpcenter.dao.TbEntMemberIdentifyCapitalMapper;
import com.youxin.cpcenter.dao.TbEntMemberInfoMapper;
import com.youxin.cpcenter.model.TbEntMemberIdentifyCapital;
import com.youxin.cpcenter.service.MemberNumberService;

/**
 * @description 
 * @author yingde.cao
 * @date 2017年12月12日
 * @version 1.0
 */
@Service("memberNumberService")
public class MemberNumberServiceImpl implements MemberNumberService{

	@Autowired
	private TbEntMemberIdentifyCapitalMapper tbEntMemberIdentifyCapitalMapper;
	@Autowired
	private TbEntMemberInfoMapper tbEntMemberInfoMapper;
	@Override
	public boolean isCanConsumer(long entIdentity) {		
		LeadsStatTotalBean totalObject=tbEntMemberInfoMapper.queryStatMemberNumber(entIdentity);		
		TbEntMemberIdentifyCapital tbEntMemberIdentifyCapital=tbEntMemberIdentifyCapitalMapper.selectByPrimaryKey(entIdentity);	
		int number=tbEntMemberIdentifyCapital.getTotalMemberNumber().intValue()-totalObject.getTotal().intValue();
		return number>0;
	}

	/* (non-Javadoc)
	 * @see com.youxin.cpcenter.service.MemberNumberService#increaseMemberNumber(long, int)
	 */
//	public boolean increaseMemberNumber(long entIdentity)
//	{
//		return increaseMemberNumber(entIdentity, 1);
//	}
//	@Override
//	public boolean increaseMemberNumber(long entIdentity, int number) {
//		TbEntMemberIdentifyCapital tbEntMemberIdentifyCapital=new TbEntMemberIdentifyCapital();
//		tbEntMemberIdentifyCapital.setId(entIdentity);
//		tbEntMemberIdentifyCapital.setUpdateTime(System.currentTimeMillis());
//		tbEntMemberIdentifyCapital.setMemberNumber(number);
//		int rowEffected=tbEntMemberIdentifyCapitalMapper.increaseMemberNumber(tbEntMemberIdentifyCapital);
//		
//		return rowEffected==1;
//	}

	/* (non-Javadoc)
	 * @see com.youxin.cpcenter.service.MemberNumberService#decreaseMemberNumber(long)
	 */
//	@Override
//	public boolean decreaseMemberNumber(long entIdentity) {
//		TbEntMemberIdentifyCapital tbEntMemberIdentifyCapital=new TbEntMemberIdentifyCapital();
//		tbEntMemberIdentifyCapital.setId(entIdentity);
//		tbEntMemberIdentifyCapital.setUpdateTime(System.currentTimeMillis());
//		tbEntMemberIdentifyCapital.setMemberNumber(1);
//		int rowEffected=tbEntMemberIdentifyCapitalMapper.decreaseMemberNumber(tbEntMemberIdentifyCapital);
//		
//		return rowEffected==1;
//	}

}
